import abstract_player
import cards

class HumanPlayer(abstract_player.AbstractPlayer):
    def __init__(self, game, name):
        abstract_player.AbstractPlayer.__init__(self)
        
        self.game = game
        self.name = name
    
    def do_move(self):
        print(self.name + "'s turn. Your hole cards are " + cards.card_names(self.hole_cards) + ".")
        
        if self.game.checkable(self.current_bet):
            move = input("Do you want to fold (f), check (c), or bet (b [amount]): ").rstrip()
            if move == "c":
                self.check()
                return
            elif move.startswith("b"):
                self.bet(int(move.split()[1]))
                return
        else:
            move = input("Do you want to fold (f), call $" + str(self.game.current_bet - self.current_bet) + " (c), or raise (r [amount]): ").rstrip()
            if move == "c":
                self.call()
                return
            elif move.startswith("r"):
                self.raise_amount(int(move.split()[1]))
                return
        
        if move == "f": 
            self.fold()
            return
            
        print("Unknown command. Try again.")
        self.do_move()
    
    def __str__(self):
        return self.name + " (h)"